<?xml version="1.0" encoding="iso-8859-1"?>

<!-- 
  -- Please see the readme.txt file included with this distribution for 
  -- attribution and copyright information.
  -->

<root version="2.0">
	<windowclass name="charsheet">
		<frame>charsheet</frame>
		<placement>
			<size>
				<width>525</width>
				<height>611</height>
			</size>
			<position>
				<x>410</x>
				<y>90</y>
			</position>
		</placement>
		<minimize />
		<nodelete />
		<playercontrol />
		<script file="scripts/charsheet_toplevel.lua" />
		<sheetdata>
			<windowreferencecontrol>
				<bounds>10,-25,40,15</bounds>
				<icon>
					<normal>button_minisheet</normal>
					<pressed>button_minisheet_down</pressed>
				</icon>
				<class>charsheetmini_top</class>
				<tooltip>
					<text>Mini sheet</text>
				</tooltip>
				<script>
					function onClickRelease(button, x, y)
						local wnd = Interface.findWindow("charsheetmini_top", window.getDatabaseNode());
						if wnd then
							wnd.close();
						else
							wnd = Interface.openWindow("charsheetmini_top", window.getDatabaseNode());

							local tabindex = window.tabs.getIndex();
							if tabindex == 1 or tabindex == 2 or tabindex == 7 then
								wnd.tabs.activateTab(1);
							elseif tabindex == 3 or tabindex == 4 then
								wnd.tabs.activateTab(2);
							elseif tabindex == 5 then
								wnd.tabs.activateTab(3);
							elseif tabindex == 6 then
								wnd.tabs.activateTab(4);
							end
						end
						return true;
					end
				</script>
			</windowreferencecontrol>

			<subwindow name="main">
				<bounds>0,0,-1,-22</bounds>
				<class>charsheet_main</class>
			</subwindow>
			<subwindow name="combat">
				<bounds>0,0,-1,-22</bounds>
				<class>charsheet_combat</class>
			</subwindow>
			<subwindow name="skills">
				<bounds>0,0,-1,-22</bounds>
				<class>charsheet_skills</class>
			</subwindow>
			<subwindow name="abilities">
				<bounds>0,0,-1,-22</bounds>
				<class>charsheet_abilities</class>
			</subwindow>
			<subwindow name="inventory">
				<bounds>0,0,-1,-22</bounds>
				<class>charsheet_inventory</class>
			</subwindow>
			<subwindow name="powers">
				<bounds>0,0,-1,-22</bounds>
				<class>charsheet_powers</class>
			</subwindow>
			<subwindow name="notes">
				<bounds>0,0,-1,-22</bounds>
				<class>charsheet_notes</class>
			</subwindow>

			<tabcontrol name="tabs">
				<bounds>-22,50,18,492</bounds>
				<tab>
					<icon>tab_main</icon>
					<subwindow>main</subwindow>
				</tab>
				<tab>
					<icon>tab_combat</icon>
					<subwindow>combat</subwindow>
				</tab>
				<tab>
					<icon>tab_skills</icon>
					<subwindow>skills</subwindow>
				</tab>
				<tab>
					<icon>tab_abilities</icon>
					<subwindow>abilities</subwindow>
				</tab>
				<tab>
					<icon>tab_inventory</icon>
					<subwindow>inventory</subwindow>
				</tab>
				<tab>
					<icon>tab_powers</icon>
					<subwindow>powers</subwindow>
				</tab>
				<tab>
					<icon>tab_notes</icon>
					<subwindow>notes</subwindow>
				</tab>
				<activate>1</activate>
			</tabcontrol>
		
			<closebutton_charsheet />
		</sheetdata>
	</windowclass>

	<windowclass name="charsheetmini_top">
		<frame>charsheet</frame>
		<placement>
			<size>
				<width>450</width>
				<height>480</height>
			</size>
			<position>
				<x>410</x>
				<y>90</y>
			</position>
		</placement>
		<sizelimits>
			<minimum>
				<width>450</width>
				<height>480</height>
			</minimum>
			<dynamic>
				<resize>both</resize>
			</dynamic>
		</sizelimits>
		<minimize />
		<nodelete />
		<playercontrol />
		<script file="scripts/charsheet_toplevel.lua" />
		<sheetdata>
			<genericcontrol name="mini_top_frame">
				<bounds>10,20,-22,40</bounds>
				<frame>
					<name>sheetgroup</name>
				</frame>
			</genericcontrol>
			<stringfield name="name">
				<font>sheettext</font>
				<frame>
					<name>textline</name>
				</frame>
				<anchored>
					<to>mini_top_frame</to>
					<position>insidetopleft</position>
					<offset>15,10</offset>
					<size>
						<width>120</width>
						<height>20</height>
					</size>
				</anchored>
				<script>
					function onInit()
						setReadOnly(true);
					end
				</script>
			</stringfield>
			<stringfield name="race">
				<font>sheettext</font>
				<frame>
					<name>textline</name>
				</frame>
				<anchored>
					<to>mini_top_frame</to>
					<position>insidetopleft</position>
					<offset>145,10</offset>
					<size>
						<width>100</width>
						<height>20</height>
					</size>
				</anchored>
				<script>
					function onInit()
						setReadOnly(true);
					end
				</script>
			</stringfield>
			<stringcontrol name="class">
				<font>sheettext</font>
				<frame>
					<name>textline</name>
				</frame>
				<anchored>
					<to>mini_top_frame</to>
					<left>
						<parent>mini_top_frame</parent>
						<anchor>left</anchor>
						<offset>255</offset>
					</left>
					<top>
						<parent>mini_top_frame</parent>
						<anchor>top</anchor>
						<offset>10</offset>
					</top>
					<right>
						<parent>mini_top_frame</parent>
						<anchor>right</anchor>
						<offset>-45</offset>
					</right>
					<size>
						<height>20</height>
					</size>
				</anchored>
				<script>
					function updateValue()
						local value = "";
						local main_node = window.getDatabaseNode();
						if main_node then
							local class1 = main_node.getChild("class.base");
							if class1 then
								if class1.getValue() ~= "" then
									if value ~= "" then
										value = value .. " / ";
									end
									value = value .. class1.getValue();
								end
							end
							local class2 = main_node.getChild("class.paragon");
							if class2 then
								if class2.getValue() ~= "" then
									if value ~= "" then
										value = value .. " / ";
									end
									value = value .. class2.getValue();
								end
							end
							local class3 = main_node.getChild("class.epic");
							if class3 then
								if class3.getValue() ~= "" then
									if value ~= "" then
										value = value .. " / ";
									end
									value = value .. class3.getValue();
								end
							end
						end
						
						setValue(value);
					end
					
					function onInit()
						setReadOnly(true);
						
						local main_node = window.getDatabaseNode();
						if main_node then
							local class1 = main_node.getChild("class.base");
							if class1 then
								class1.onUpdate = updateValue;
							end
							local class2 = main_node.getChild("class.paragon");
							if class2 then
								class2.onUpdate = updateValue;
							end
							local class3 = main_node.getChild("class.epic");
							if class3 then
								class3.onUpdate = updateValue;
							end
						end

						updateValue();
					end
				</script>
			</stringcontrol>
			<sheetnumber name="level">
				<anchored>
					<to>mini_top_frame</to>
					<top>
						<parent>mini_top_frame</parent>
						<anchor>top</anchor>
						<offset>10</offset>
					</top>
					<right>
						<parent>mini_top_frame</parent>
						<anchor>right</anchor>
						<offset>-15</offset>
					</right>
					<size>
						<width>25</width>
						<height>20</height>
					</size>
				</anchored>
				<frame>
					<name>bonus</name>
					<offset>5,4,5,4</offset>
				</frame>
			</sheetnumber>

			<!-- ACTIVATE IDENTITY -->
			<buttoncontrol>
				<bounds>-35,30,23,22</bounds>
				<icon>
					<normal>button_identityactivate</normal>
					<pressed>button_identityactivate_down</pressed>
				</icon>
				<script>
					function onButtonPress()
						if User.isHost() then
							GmIdentityManager.addIdentity(window.name.getValue());
						else
							local identityname = window.getDatabaseNode().getName();

							User.setCurrentIdentity(identityname);

							if CampaignRegistry and CampaignRegistry.colortables and CampaignRegistry.colortables[identityname] then
								local colortable = CampaignRegistry.colortables[identityname];
								User.setCurrentIdentityColors(colortable.color or "000000", colortable.blacktext or false);
							end
						end
					end
				</script>
			</buttoncontrol>
		

			<subwindow name="main">
				<bounds>10,50,-22,-1</bounds>
				<class>charsheetmini_basic</class>
			</subwindow>
			<subwindow name="abilities">
				<bounds>10,50,-22,-1</bounds>
				<class>charsheetmini_abilities</class>
			</subwindow>
			<subwindow name="inventory">
				<bounds>10,50,-22,-1</bounds>
				<class>charsheetmini_inventory</class>
			</subwindow>
			<subwindow name="powers">
				<bounds>10,50,-22,-1</bounds>
				<class>charsheetmini_powers</class>
			</subwindow>
			
			<windowreferencecontrol>
				<bounds>10,-25,40,15</bounds>
				<icon>
					<normal>button_fullsheet</normal>
					<pressed>button_fullsheet_down</pressed>
				</icon>
				<class>charsheet</class>
				<tooltip>
					<text>Full Sheet</text>
				</tooltip>
				<script>
					function onClickRelease(button, x, y)
						local wnd = Interface.findWindow("charsheet", window.getDatabaseNode());
						if wnd then
							wnd.close();
						else
							wnd = Interface.openWindow("charsheet", window.getDatabaseNode());

							local tabindex = window.tabs.getIndex();
							if tabindex == 1 then
								wnd.tabs.activateTab(1);
							elseif tabindex == 2 then
								wnd.tabs.activateTab(4);
							elseif tabindex == 3 then
								wnd.tabs.activateTab(5);
							elseif tabindex == 4 then
								wnd.tabs.activateTab(6);
							end
						end
						return true;
					end
				</script>
			</windowreferencecontrol>

			<tabcontrol name="tabs">
				<bounds>-22,50,18,291</bounds>
				<tab>
					<icon>tab_main</icon>
					<subwindow>main</subwindow>
				</tab>
				<tab>
					<icon>tab_abilities</icon>
					<subwindow>abilities</subwindow>
				</tab>
				<tab>
					<icon>tab_inventory</icon>
					<subwindow>inventory</subwindow>
				</tab>
				<tab>
					<icon>tab_powers</icon>
					<subwindow>powers</subwindow>
				</tab>
				<activate>1</activate>
			</tabcontrol>
			
			<closebutton_charsheetmini />
		</sheetdata>
	</windowclass>
</root>
